package mirfordevoservice.system.req;

import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * Created by Heart!
 *
 * @Author ZhangChaoJian
 * @Date ${Date}-20:25
 * Wants More Then Try Hard More!
 */
public class ReqManager {
    private static ReqManager ourInstance = new ReqManager();

    public static ReqManager getInstance() {
        return ourInstance;
    }

    private ReqManager() {
    }

    /**
     * 按照协议定好的消息个数读取消息
     *
     * @param count
     * @param in
     * @return
     */
    public Object[] readMsg(int count, ObjectInputStream in) {
        Object[] objects = new Object[count];
        for (int i = 0; i < count; i++) {
            try {
                objects[i] = in.readObject();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        return objects;
    }
}
